#include "Simulation.h"

#include <iostream>

Simulation::Simulation(Robot &_oRobot)
: m_oRobot(_oRobot)
{

}


void Simulation::run()
{
	const char *sRobotName = this->m_oRobot.getName();
	eOption eUserOption;
	unsigned int uiUserOption;

	while(true)
	{
		this->displayOption();

		cout << "Your choice : ";
		cin >> uiUserOption;
		cout << endl;

		eUserOption = (eOption) uiUserOption;

		switch(eUserOption)
		{
		case eDisplayRobotMaterials:
			{
				cout << sRobotName << "'s materials : " << endl;
				cout << this->m_oRobot.reportMaterialList() << endl;
				break;
			}

		case eDisplayRoomMaterials :
			{
				cout << sRobotName << " see in this room : " << endl;
				cout << this->m_oRobot.getRoom().reportMaterialList() << endl;
				break;
			}

		case eDisplayRoomNameAndExits:
			{
				cout << "this room is named " << this->m_oRobot.getRoom().getName() << "." << endl;
				cout << sRobotName << " can go to : " << endl;
				cout << this->m_oRobot.getRoom().reportExitList() << endl;
				break;
			}
		case eMoveToAnotherRoom:
			{
				int iExitNumber;
				cout << "Exit number : ";
				cin >> iExitNumber;
				cout << endl;

				if(this->m_oRobot.takeExit(iExitNumber-1))
				{
					cout << sRobotName << " took the exit. " << iExitNumber << endl;
				}
				else
				{
					cout << "Incorrect exit number !!! >_<" << endl;
				}
				break;
			}

		case ePutDownMaterials:
			{
				this->m_oRobot.putDownMaterials();
				cout << sRobotName << " put down all its materials." << endl;
				break;
			}

		case eTakeRoomMaterials:
			{
				this->m_oRobot.takeMaterials();
				cout << sRobotName << " took all room's materials." << endl;
				break;
			}

		case eStopSimulation: return;
		default:
			cout << "Incorrect choice !!! >_<" << endl;
			break;
		}
	}
}

void Simulation::displayOption() const
{
	const char *sRobotName = this->m_oRobot.getName();

	cout << endl << "-------------------------------------------" << endl;
	cout << "You want to kown : " << endl;
	cout << " 1 - what is carrying " << sRobotName << "?" << endl;
	cout << " 2 - where is " << sRobotName << "?" << endl;
	cout << " 3 - what does " << sRobotName << " see in this room?" << endl;
	cout << "You want to do : " << endl;
	cout << " 4 - Make " << sRobotName << " moving to another room." << endl;
	cout << " 5 - Make " << sRobotName << " taking all materials in this room." << endl;
	cout << " 6 - Make " << sRobotName << " puting down all its materials." << endl;
	cout << " 7 - Stop simulation." << endl;
	cout << "-------------------------------------------" << endl;
}